$OpenBSD: patch-src_networks_donkey_donkeyOvernet_ml,v 1.1 2016/11/23 14:16:10 dcoppa Exp $

commit f8d595df4fe01512fd945bb6d524958d1361a0a8
Author: ygrek <ygrek@autistici.org>
Date:   Mon Jul 25 19:44:40 2016 -0700

other fixes for 4.03

--- src/networks/donkey/donkeyOvernet.ml.orig	Wed Nov 23 14:54:30 2016
+++ src/networks/donkey/donkeyOvernet.ml	Wed Nov 23 14:55:33 2016
@@ -1446,25 +1446,20 @@ let compute_to_ping () =
 
 (* start max three searches for sources *)
 let start_max_source_searches () =
+  let current_files2 = ref [] in
+  while (List.length !overnet_searches) < 3 && !current_files <> [] do
+    match !current_files with
+    | [] -> assert false
+    | (file, start, last) :: tl ->
+      current_files := tl;
+      if file_state file = FileDownloading && (last + 900) < last_time () then
       begin
-          let current_files2 = ref [] in
-          (try
-            while (List.length !overnet_searches) < 3 && !current_files <> [] do
-              let (file, start, last) = List.hd !current_files in
-	      current_files := List.tl !current_files;
-              if file_state file = FileDownloading &&
-	         (last + 900) < last_time () then begin
-	        ignore (create_search (FileSearch file) file.file_md4);
-   	        current_files2 := (file, start, last_time ()) :: !current_files2;
-	      end else
-   	        current_files2 := (file, start, last) :: !current_files2;
-	    done;
-	  with Failure "hd" -> ()
-	     | Failure "tl" -> (); );
-          List.iter (fun (file, start, last) ->
-            current_files := (file, start, last) :: !current_files
-	  ) !current_files2;
-       end	
+        ignore (create_search (FileSearch file) file.file_md4);
+        current_files2 := (file, start, last_time ()) :: !current_files2;
+      end else
+        current_files2 := (file, start, last) :: !current_files2;
+  done;
+  List.iter (fun (file, start, last) -> current_files := (file, start, last) :: !current_files) !current_files2
 
 let enable () =
   if !!enable_overnet && not !is_enabled then begin
